subroutine SelfDefined(matrix_1,matrix_2,rowNum_1,colNum_1,rowNum_2,colNum_2,matrix_result,result_row,result_col,flag)
  integer::rowNum_1,colNum_1,rowNum_2,colNum_2,result_row,result_col,flag
  
  REAL*8 matrix_1(rowNum_1,colNum_1),matrix_2(rowNum_2,colNum_2),matrix_result(result_row,result_col)

  !REAL*8,dimension(:):: matrix_1,matrix_2,matrix_result


  if( (rowNum_1 .ne. rowNum_2) .or. (colNum_1 .ne. colNum_2)) then
     print *,"the two matrices dimension do not agree, cannot perform addition, program terminated"
     stop
  endif

    matrix_result = 0


  do i=1,rowNum_1
     do j=1,ColNum_1
        matrix_result(i,j) = Matrix_1(i,j) + Matrix_2(i,j)
     enddo
  enddo
  
  flag = 1

  return
end subroutine SelfDefined
